#!/usr/bin/env python
# Create: 2018/11/23
__author__ = '749B'

import logging

from backend.ssh_client import SSHClient

logger = logging.getLogger(__name__)


class SFTPClient(SSHClient):

    def __init__(self, node, *args, **kwargs):
        super(SFTPClient, self).__init__(*args, **kwargs)
        self.node = node

    def main(self):
        self.get_ssh()
        res, err = self.exec_command("ls %s" % self.filename)
        if not res:
            logger.error("没有找到任何文件: %s" % self.filename)
            self.ssh.close()
            return
        self.sftp_files(res, self.node)
        self.ssh.close()


